home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / etc / acpi / sonybright.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  2008-10-14  |  865b  |  30 lines

  1. #!/bin/bash
  2. # TODO: Change above to /bin/sh
  3.  
  4. test -f /usr/share/acpi-support/key-constants || exit 0
  5.  
  6. BRIGHTNESS=$(cat /sys/class/backlight/sony/brightness)
  7.  
  8. if [ "$BRIGHTNESS" -gt 7 ]; then
  9.     BRIGHTNESS=0
  10. fi
  11.  
  12. if [ "x$1" = "xdown" ]; then
  13.    if [ "x$BRIGHTNESS" != "x0" ]; then
  14.       BRIGHTNESS=$(( $BRIGHTNESS - 1 ))
  15.       echo $BRIGHTNESS > /sys/class/backlight/sony/brightness
  16.    else
  17.       [ -x /usr/bin/spicctrl ] && /usr/bin/spicctrl -b 0   
  18.    fi
  19.    # Recent nvidia Sonys have ACPI methods that do nothing. Thanks, Sony.
  20.    [ -x /usr/bin/smartdimmer ] && smartdimmer -d 2>/dev/null
  21. elif [ "x$1" = "xup" ]; then
  22.    if [ "x$BRIGHTNESS" != "x7" ]; then
  23.       BRIGHTNESS=$(( $BRIGHTNESS + 1 ))
  24.       echo $BRIGHTNESS > /sys/class/backlight/sony/brightness
  25.    fi
  26.    [ -x /usr/bin/smartdimmer ] && smartdimmer -i 2>/dev/null
  27. else
  28.    echo >&2 Unknown argument $1
  29. fi
  30.